package strcy.cn.market.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import strcy.cn.market.pojo.ShoppingCarts;
import strcy.cn.market.pojo.VO.ShoppingCartsVO;

import java.util.List;

@Mapper
public interface ShoppingCartsMapper {
    //加入购物车
    @Insert("insert into shopping_carts(user_id, product_id, quantity, added_at) " +
            "value (#{userId},#{productId},#{quantity},now())")
    void add(ShoppingCarts shoppingCarts);
    //修改商品数量
    @Update("update shopping_carts set quantity=#{quantity} where cart_id=#{cartId}")
    void update(Integer quantity, Integer cartId);
    //购物车列表
    List<ShoppingCartsVO> list(Integer userId);
    //根据用户Id和购物车Id 删除购物车
    @Delete("delete from shopping_carts where cart_id=#{cartId}")
    void deleteById(Integer cartId);
    //批量删除购物车
    void deleteByIds(List<Integer> cartId);
}
